
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "CBLEDataMnger.h"
#import "CBLEDataMsg.h"

NS_ASSUME_NONNULL_BEGIN

//作为中央设备
@interface CBLECenterMnger : NSObject<CBCentralManagerDelegate>
@property (nonatomic, assign) BOOL              bIsPowerOn;     //蓝牙是否上电
@property (nonatomic, strong) CDataPheralMnger* dataPherals;    //所有的外围设备
@property (nonatomic, strong) CDataPheralInfo*  curPheral;      //当前连接的外围设备
@property (nonatomic, assign) BOOL isManualDisconnect;     //设备是否手动断开,如果是则不需要重连
@property (nonatomic, copy) NSString *disconnectDevUUid;   //断开的设备
//授权状态确认后的回调
@property (nonatomic, copy) void(^authBlock)(CBManagerState);
/*!
 *  desc    : 创建全局蓝牙管理中心
 *  @return : 返回蓝牙管理中心对象单例
 */
+ (nullable CBLECenterMnger *)shareMnger;
+ (BOOL)BLEIsPowerOff;
+ (void)checkAuthState:(void(^)(CBManagerState))authBlock;

//蓝牙中心设备命令
- (void)cmdStopScan;
- (void)cmdStartScan;
- (BOOL)isScaning;
- (BOOL)isCanScan;
- (BOOL)isConnectOK;
- (void)cmdConnect2Pheral:(CDataPheralInfo*)pheral;
- (void)cmdDisconnectCurPheral;
//连接本地保存过设备(采用设备名连接);
- (void)connectLocalPeripheral:(CDataPheralInfo*)pheral;
@end

@interface CBLECenterMnger (BLEWristCmd)
- (void)wristWriteOTACmd:(NSData*)data bInOTA:(BOOL)bInOTA;
- (void)wristWriteOTAData:(NSData*)data;
///发送一般的写指令
- (void)wristWriteData:(NSData*)data;
- (void)wristReadData:(NSData*)data;
    
- (void)wristCmdSetLED:(NSUInteger)nChannel nVal:(NSUInteger)nVal;
- (void)wristCmdStartSensor:(BOOL)bStart;
- (void)wristCmdStartHR:(BOOL)bStart;
- (void)wristNotifyNewMsg:(NSUInteger)nMsgType;
- (void)wristSendMsgByWeChat:(NSString*)strBrief strMsg:(NSString*)strMsg;
- (void)wristSendMsgBySMS:(NSString*)strBrief strMsg:(NSString*)strMsg;
- (void)wristSendMsgMore;

//发送Wi-Fi
- (BOOL)wristSsidMsg:(NSData*)data;
- (BOOL)wristPassMsg:(NSData*)data;

@end


@interface CBLECenterMnger (BLEWristOTACmdInApp)
-(void)appCmdSwitch2OTA;
-(void)appCmdSwitch2OTARes;
-(void)appCmdVersion;
@end


@interface CBLECenterMnger (BLEWristOTACmdInOTA)
-(void)otaCmd2App;
-(void)otaCmsStart:(NSInteger)nPartitionNums;
@end











NS_ASSUME_NONNULL_END
